using AutoMapper;
using OTE.Contract;
using OTE.Domain;

namespace OTE.Web.Infrastructure.AutoMapper.Profiles
{
    public class QuestionProfile : Profile
    {
        protected override void Configure()
        {
            Mapper.CreateMap<Question, QuestionDTO>()
                .ForMember(x => x.Id, o => o.MapFrom(m => m.Id))
                .ForMember(x => x.CategoryId, o => o.MapFrom(m => m.Category != null ? m.Category.Id : -1))
                .ForMember(x => x.UserId, o => o.MapFrom(m => m.User != null ? m.User.Id : -1))
                .ForMember(x => x.CreatedBy, o => o.MapFrom(m => m.CreatedBy))
                .ForMember(x => x.CreatedDate, o => o.MapFrom(m => m.CreatedDate))
                .ForMember(x => x.ModifiedBy, o => o.MapFrom(m => m.ModifiedBy))
                .ForMember(x => x.ModifiedDate, o => o.MapFrom(m => m.ModifiedDate));

            Mapper.CreateMap<QuestionDTO, Question>()
                .ForMember(x => x.Id, o => o.MapFrom(m => m.Id))
                .ForMember(x => x.CreatedBy, o => o.MapFrom(m => m.CreatedBy))
                .ForMember(x => x.CreatedDate, o => o.MapFrom(m => m.CreatedDate))
                .ForMember(x => x.ModifiedBy, o => o.MapFrom(m => m.ModifiedBy))
                .ForMember(x => x.ModifiedDate, o => o.MapFrom(m => m.ModifiedDate));
        }
    }
}